#include <boost/foreach.hpp>

#include "WaveFileDescriptor.h"
#include "XmlUtils.h"

using namespace std;

WaveFileDescriptor::WaveFileDescriptor(void)
{
    m_waveList.clear();
}

WaveFileDescriptor::~WaveFileDescriptor(void)
{
}

void WaveFileDescriptor::parse(const string& filename) throw (...)
{
    // Read all content from input file and store it into a single string
    string fileContent = XmlUtils::readAll(filename);
    // Parse the whole XML file
    XmlDocument doc;
    doc.parse<0>(const_cast<char *>(fileContent.c_str()));

    // Parse waves information
    BOOST_FOREACH(XmlNode *node, XmlUtils::getNodes("wave_list.wave", doc))
    {
        WaveInfo wave;
        wave.parse(node);
        m_waveList.push_back(wave);
    }
}
